Conversation
- Added 'team' and 'spawn_sub_agent' tools to support Coordinator-Worker patterns. - Implemented execution strategies: Sequential, Parallel, DAG, and Evaluator-Optimizer. - Added global token budget tracking via 'RemainingTokenBudget' for team cost control. - Designed 'ConcurrencyUpgradeable' interface and 'ConcurrentFS' wrapper for opt-in, thread-safe file operations during parallel/DAG runs. - Tested file locking mechanisms preventing race conditions during high concurrency.
- Added 'model' property to 'team' and 'spawn_sub_agent' JSON schemas. - Modified 'buildWorkerConfig' to override 'baseConfig.Model' when a specific LLM model is requested by the coordinator. - Allows teams to dynamically mix and match specialized vision, coding, and logical models within the same execution loop.
- Added ModelTag* constants (vision, code, fast, long-context, reasoning) to subagent.go - Added Tags []string to config.ModelConfig (json:"tags,omitempty") - Piped tags from config through FallbackCandidate and into SubagentManager.allowedModels - Changed ResolveCandidatesWithLookup lookup signature to return (string, []string, bool) to carry tags - Added ModelCapabilityHint() that generates rich per-model routing guidance for the LLM - Dynamically injected capability hints into TeamTool and SpawnSubAgentTool descriptions - Fixed fallback_test.go and subagent test files to match updated signatures
- context.go: add Rule sipeed#5 'Team delegation' to system prompt — agents now instructed to proactively use 'team' for multi-step/multi-concern tasks instead of handling them inline - team.go: add 'WHEN TO USE THIS TOOL' activation triggers to tool description; strengthen decomposition rules with domain-agnostic project-manager framing - loop.go: call subagentManager.SetTools(agent.Tools) after full registry is built so sub-agents inherit 'team' tool for recursive hierarchical decomposition - toolloop.go: replace hard token budget failure with soft graceful degradation (50% advisory warning, 0% wrap-up signal + final summary call); add truncation recovery for max_tokens cutoff (finish_reason=truncated) - openai_compat/provider.go: detect truncated JSON tool calls and set FinishReason='truncated' instead of silently storing malformed raw args
- Added Produces string field to TeamMember struct - Added 'produces' property to team tool JSON schema - Added reviewerTaskTemplates map for code/data/document artifact types - Added maybeRunAutoReviewer() helper that auto-injects a QA reviewer agent after all workers complete when any member declares a produces type - Wired reviewer into sequential, parallel, and dag execution strategies - evaluator_optimizer skipped (already has built-in critique loop)
Team Tool Configuration GuideThe Configuration LocationSettings are located in Comprehensive Example{
"tools": {
"team": {
"enabled": true,
"max_members": 5,
"max_team_tokens": 100000,
"max_evaluator_loops": 3,
"max_timeout_minutes": 20,
"max_context_runes": 8000,
"disable_auto_reviewer": false,
"reviewer_model": "gpt-4o-mini",
"allowed_strategies": [
"sequential",
"parallel",
"dag",
"evaluator_optimizer"
],
"allowed_models": [
{
"name": "gpt-4o",
"tags": ["vision", "code", "reasoning"]
},
{
"name": "claude-3-5-sonnet",
"tags": ["coding", "precise"]
}
]
}
}
}Field Reference
Feature Highlights1. Robust ParallelismIn Parallel mode, if some workers fail while others succeed, the tool returns Partial Success. Successful results are preserved, and failures are summarized separately so the coordinator can decide how to proceed. 2. Context TruncationTo prevent "Token Bombs," the tool automatically truncates long outputs when injecting them as dependencies/context for downstream workers. You can tune this via 3. Dedicated QA ReviewerThe Auto-Reviewer automatically validates artifacts like code or documentation. By setting 4. DAG Pipeline safetyThe DAG strategy implements Cycle Detection (Kahn's Algorithm). If the LLM proposes a circular dependency, the tool will intercept and report it as an error before wasting tokens. |
…entation - Fixed dead code in token budget clamping - Fixed goroutine leak in DAG strategy fast-fail path - Optimized Evaluator to run without tools in evaluator_optimizer - Added partial success support to Parallel strategy - Implemented configurable context truncation via max_context_runes - Added reviewer_model support for cost-efficient QA - Added structured logging across all strategies - Improved ForUser messages with role summaries - Merged and updated team configuration documentation
|
Hi team! 👋 Just wanted to highlight that this PR (#976: feat: agent team) is directly building on and extending the foundational multi-agent work outlined in Issue #294 ("Feature: Base Multi-agent Collaboration Framework & Shared Context"), which is still marked as In Progress and is a key part of the Roadmap's Advanced Capabilities.
This PR implements exactly that missing layer:
It stays compatible with the existing sub-agent foundation (#409/#423) while adding reliable coordination for complex decomposed tasks — precisely what #294 aims to enable as the base for community agents (Coder, Researcher, etc.), swarm mode, and beyond. No conflicts, CI green, rebased on main. Would really appreciate any initial feedback or eyes from the core team on:
Super happy to iterate further (add tests, break into smaller PRs if needed, or discuss details). This feels like a natural progression to help close #294 and unlock the full multi-agent potential in PicoClaw! 🚀 Thanks for the incredible momentum (v0.2.2 release yesterday, constant merges) — excited to contribute to this growth. Best regards, |
- Merge feat/team: integrate multi-agent orchestration tool into main. - Fix Team Tool bugs: resolve DAG goroutine leaks and token budget clamping. - Optimize Team strategies: implement text-only evaluator and partial parallel success. - Enhance observability: add structured logging and improved user summaries. - Expand configuration: add max_context_runes and reviewer_model settings. - Refactor context builder: implement cached system prompt and simplified dynamic context. - Align with upstream: remove local Embedding support and custom truncation logic for better parity. - Documentation: update tools_configuration.md with detailed Team tool guide.
- Update TeamTool to accept and use global configuration - Refactor buildWorkerConfig into a TeamTool method for better context handling - Improve error handling in DAG and sequential execution flows - Add comprehensive unit tests for TeamTool sequential execution - Clean up imports and formatting in toolloop.go and config.go
- Retain and during multi-turn tool calls to resolve API 400 errors (missing a thought_signature). - Append the final assistant message to the session history before exiting the loop, fixing the state memory loss issue in the team strategy. - Add fallback to when standard content is empty (e.g., for Gemini 2.0 Pro Thinking). - Preserve during token budget exhaustion and truncation recovery to prevent broken chain-of-thought.
|
Hi, Thank you for the thoughtful and focused proposal in #1439! While working on PR #976 (multi-agent team orchestration), I encountered several of the same context/token pain points in concurrent multi-agent scenarios and applied some patch-style fixes directly on the existing loop to improve reliability. These are not new mechanisms but simple adjustments that might help illustrate or validate the boundary clarifications and correctness improvements outlined in #1439. Here are the relevant existing fixes in #976 that align with the proposal's goals:
All of these are straightforward patches on the current agent loop (50 commits total, CI green, rebased on main), not new features. They were added to make multi-agent flows more robust in practice. Once the boundary clarifications and correctness fixes from #1439 are applied in the refactor/agent branch, I'm happy to:
If any of these existing patches can serve as a quick reference for testing the boundary definitions or proactive shifts (e.g., does the soft budget reduce abrupt failures? do the truncation rules prevent orphaning?), feel free to review them — I'd be glad to point to specific sections, share diffs, or assist in porting them. Thanks again for driving this important track forward — excited to see the context foundation become more solid and predictable! |
|
Closing this PR (#976) as we have now opened a clean v2 version: New PR → Reason for closing:
This PR has served its purpose. v2 completely supersedes #976. Thank you very much for the previous reviews on #976! |
📝 Description
Implements a multi-agent Teams architecture for PicoClaw, enabling the coordinator agent to decompose complex tasks and delegate to specialized sub-agents running concurrently as goroutines.
Key features added:
teamtool: orchestrate multi-agent pipelines withsequential,parallel,dag, andevaluator_optimizerstrategiesspawn_sub_agenttool: delegate a single isolated task to a sub-agentmodelfield allows routing tasks to different LLMs (e.g., vision model for screenshots, code model for generation)tags: annotate models with capability labels (vision,code,fast,long-context,reasoning,image-gen) to guide the coordinator's routing decisionsproduces: "code"/"data"/"document"to trigger an automatic QA reviewer after all workers completefinish_reason=lengthand injects a retry message instead of looping on malformed JSON🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
N/A
📚 Technical Context
🧪 Test Environment
☑️ Checklist